class Solution34 {
    public int[] searchRange(int[] nums, int target) {
         int len = nums.length ;
         if(len == 0){
            return new int[]{-1,-1} ;
         }
         int left = 0 ; 
         int right =len-1 ;
         int[] arr = new int[2] ; 
         // 找左边界
         while(left < right){
            int mid = left + (right-left)/2 ;
            if(nums[mid] < target){
                left = mid+1 ;
            } else{
                right = mid ;
            }
         }
         if(nums[left] != target){
            return new int[]{-1,-1} ; 
         }
        //  找右边界
        arr[0] = left ; 
        left = 0 ; 
        right = len-1  ; 
        while(right > left){
        int mid = left + (right-left+1)/2 ;
          if(nums[mid] > target){
            right = mid-1 ;
          }else{
            left = mid ;
          }
        }
        arr[1] = right ;
         return arr ; 
    }
}